#region Using Statements
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Xfinity.Engine;

#endregion

namespace Xfinity.Engine.Plugins
{
    /// <summary>
    /// This is a game component that implements IUpdateable.
    /// </summary>
    public partial class ParticleEmitter// : Microsoft.Xna.Framework.GameComponent
    {
        /// <summary>
        /// Construct a new particle emitter.
        /// </summary>
        /// <param name="emitterOriginType">The origin type.</param>
        /// <param name="emitterDirectionType">The direction type.</param>
        /// <param name="position">The origin of the particle system.</param>
        public ParticleEmitter(EmitterOriginType emitterOriginType, EmitterDirectionType emitterDirectionType, Vector3 position)
        {
            random = new Random();
            this.emitterOriginType = emitterOriginType;
            this.emitterDirectionType = emitterDirectionType;
        }
        Random random;
        internal virtual IEnumerable<ParticleSystem.Particle> GenerateInitialVelocities(int count, float mass, Color color)
        {
            switch (emitterOriginType)
            {
                case EmitterOriginType.Point:
                    switch (emitterDirectionType)
                    {
                        case EmitterDirectionType.Explosion:
                            for (int i = 0; i < count; i++)
                            {
                                yield return new ParticleSystem.Particle(position, new Vector3((float)(2 * random.NextDouble() - 1), (float)(2 * random.NextDouble() - 1), (float)(2 * random.NextDouble() - 1)), new Vector3((float)(2 * random.NextDouble() - 1), (float)(2 * random.NextDouble() - 1), (float)(2 * random.NextDouble() - 1)), mass, color);
                            }
                            break;
                    }
                    break;
                case EmitterOriginType.Spotlight:
                    break;
                case EmitterOriginType.Directional:
                    break;
                default:
                    break;
            }

        }

        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public void Initialize()
        {
            // TODO: Add your initialization code here

            //base.Initialize();
        }
        #region Emitter types
        private EmitterOriginType emitterOriginType;

        public EmitterOriginType EmitterOriginType
        {
            get { return emitterOriginType; }
            set { emitterOriginType = value; }
        }
        private EmitterDirectionType emitterDirectionType;

        public EmitterDirectionType EmitterDirectionType
        {
            get { return emitterDirectionType; }
            set { emitterDirectionType = value; }
        }

        #endregion
        #region Position
        private Vector3 position;

        public Vector3 Position
        {
            get { return position; }
            set { position = value; }
        }

        #endregion
        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public void Update(GameTime gameTime)
        {
            // TODO: Add your update code here

            //Update(gameTime);
        }
    }
    /// <summary>
    /// 
    /// </summary>
    public enum EmitterOriginType
    {
        /// <summary>
        /// A single point.
        /// </summary>
        Point,
        /// <summary>
        /// Focuses the particles in one direction.
        /// </summary>
        Spotlight,
        /// <summary>
        /// Kinda pointless.
        /// </summary>
        Directional
    }
    /// <summary>
    /// 
    /// </summary>
    public enum EmitterDirectionType
    {
        /// <summary>
        /// An explosion of particles in random, spherical directions.
        /// </summary>
        Explosion,
        /// <summary>
        /// A vertical stream.
        /// </summary>
        Fountain,
        /// <summary>
        /// Similiar to Fountain, except emitted from a line.
        /// </summary>
        Stream,

    }
}


